package com.gyg.bro.enums;


import com.alibaba.druid.util.StringUtils;

/**
 * @author gyg
 * @version V1.0.0
 * @description: 时间类型
 * @date 2020/12/29 18:30
 */
public enum TimeRatioEnum {
    WEEK_MONDAY("weekMonday","本周一"),
    WEEK_TODAY("weekToday","本周当天"),
    LAST_WEEK_MONDAY("lastWeekMonday","上周一"),
    LAST_WEEK_TODAY("lastWeekToday","上周当天"),
    YEAR_BEGIN("yearBegin","今年第一天"),
    YEAR_TODAY("yearToday","今年当天"),
    LAST_YEAR_BEGIN("lastYearBegin","上年第一天"),
    LAST_YEAR_TODAY("lastYearToday","上年的今天");

    private String code;
    private String desc;

    TimeRatioEnum(String code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public String getCode(){
        return this.code;
    }

    public String getDesc(){
        return this.desc;
    }

    public static TimeRatioEnum getByCode(String code){
        for (TimeRatioEnum item : TimeRatioEnum.values()) {
            if(StringUtils.equalsIgnoreCase(item.getCode(),code)){
                return item;
            }
        }
        return null;
    }


}
